package com.yunban.project.api.text_check.controller;

import com.yunban.project.api.text_check.dto.CorrectionDictReq;
import com.yunban.project.api.text_check.dto.CorrectionDictResp;
import com.yunban.project.api.text_check.service.CorrectionDictService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.EventEnum;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.PageParam;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import retrofit2.http.PUT;

/**
 * @author: lijiajun
 * @date: 2024-11-21
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "文本纠错词典管理")
@RequestMapping("/correction-dict-api")
public class CorrectionDictController {
    @Resource
    private CorrectionDictService correctionDictService;

    @GetMapping("/list")
    @Operation(summary = "文本纠错词典列表")
    PageResult<CorrectionDictResp> getDictList(PageParam req) {
        return this.correctionDictService.getDictList(req);
    }

    @PostMapping
    @Operation(summary = "保存文本纠错词典")
    Boolean saveDict(@RequestBody @Validated CorrectionDictReq req) {
        return this.correctionDictService.saveDict(req);
    }

    @PostMapping("/{id}/{event}")
    @Operation(summary = "启用禁用文本纠错词典")
    Boolean updateDictEnabled(@PathVariable long id, @PathVariable EventEnum event) {
        return this.correctionDictService.updateDictEnabled(id, event);
    }

    @PutMapping("/{id}")
    @Operation(summary = "修改文本纠错词典")
    Boolean updateDict(@PathVariable long id, @RequestBody @Validated CorrectionDictReq req) {
        return this.correctionDictService.updateDict(id, req);
    }
}
